package org.rslai.tcedit.domain;

import java.sql.Clob;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.JoinColumn;
import javax.persistence.MappedSuperclass;
import javax.persistence.OneToOne;
import javax.persistence.Transient;
import org.hibernate.annotations.Index;
import org.hibernate.validator.Length;
import org.rslai.tcedit.util.StrUtil;
import javax.persistence.*;

/**
 * 测试用例
 * 
 * @author rslai
 */
@MappedSuperclass
public class TestCase extends UUIDSupport {

	private Version version; // 版本信息
	private String catalogID; // 分类id
	private String describing; // 用例描述
	private String premiss; // 前提和约束
	private CaseState caseState; // 测试用例编写状态
	private String remark; // 备注
	private Clob steps; // 操作步骤
	private String stepsStr; // 操作步骤 字符串
	private Clob exResult; // 预期结果
	private String exResultStr; // 预期结果 字符串
	private User user; // 用户信息
	private Date editDate; // 最后编辑日期
	private String sequence; // 顺序

	@OneToOne
	@JoinColumn(nullable = false, updatable = true, unique = false)
	public Version getVersion() { return version; }
	public void setVersion(Version version) { this.version = version; }

	@Column(nullable = false, length = 32)
	@Index(name = "catalogID")
	public String getCatalogID() { return catalogID; }
	public void setCatalogID(String catalogID) { this.catalogID = catalogID; }

	@Column(nullable = false, length = 150)
	@Length(max = 100, message = "用例描述请限制在100字以内")
	public String getDescribing() { return describing; }
	public void setDescribing(String describing) { this.describing = describing; }

	@Column(nullable = true, length = 150)
	@Length(max = 100, message = "前提和约束请限制在100字以内")
	public String getPremiss() { return premiss; }
	public void setPremiss(String premiss) { this.premiss = premiss; }

	@OneToOne
	@JoinColumn(nullable = true, updatable = true, unique = false)
	public CaseState getCaseState() { return caseState; }
	public void setCaseState(CaseState caseState) { this.caseState = caseState; }

	@Column(nullable = true, length = 150)
	@Length(max = 100, message = "备注请限制在100字以内")
	public String getRemark() { return remark; }
	public void setRemark(String remark) { this.remark = remark; }

	@Lob
	@Basic(fetch = FetchType.LAZY) 
	@Column(nullable = true, length = 16777216)   
	public Clob getSteps() { return steps; }
	public void setSteps(Clob steps) {
		this.steps = steps;
		this.stepsStr = StrUtil.toString(steps);
	}
	@Transient
	public String getStepsStr() { return stepsStr; }
	@Transient
	public void setStepsStr(String stepsStr) {
		this.stepsStr = stepsStr;
		this.steps = StrUtil.toClob(stepsStr);
	}

	@Lob
	@Basic(fetch = FetchType.LAZY) 
	@Column(nullable = true, length = 16777216)   
	public Clob getExResult() { return exResult; }
	public void setExResult(Clob exResult) {
		this.exResult = exResult;
		this.exResultStr = StrUtil.toString(exResult);
	}
	@Transient
	public String getExResultStr() { return exResultStr; }
	@Transient
	public void setExResultStr(String exResultStr) {
		this.exResultStr = exResultStr;
		this.exResult = StrUtil.toClob(exResultStr);
	}

	@OneToOne
	@JoinColumn(nullable = false, updatable = true, unique = false)
	public User getUser() { return user; }
	public void setUser(User user) { this.user = user; }

	@Column(nullable = false)
	public Date getEditDate() { return editDate; }
	public void setEditDate(Date editDate) { this.editDate = editDate; }

	@Column(nullable = true, length = 5)
	public String getSequence() { return sequence; }
	public void setSequence(String sequence) { this.sequence = sequence; }

}
